<?php
	require_once '../../defines.php';
	require_once '../../includes/header.php';

	if(isLoggedIn()){
		echo "<div align='right'><a href='../../Login/logout.php'>Logout</a></div>";	
		echo "<h1>Problems</h1>";
		require_once '../../DB/connect.php';
		$probs = mysql_query("SELECT * FROM problems");
		$output = "<form method='POST' action='editProblem.php'>
			<table cellspacing='5' align='center' border=1>
			<tr><th>Edit</th><th>Title</th><th>Description</th><th>Creator</th><th>TimeStamp</th><th>Severity</th><th>Resolved?</th></tr>";
		if(mysql_num_rows($probs) > 0){
			while($prob = mysql_fetch_array($probs)){
				$output .= '<tr><td><input type="submit" value="Edit" name="'.$prob['id'].'"/></td>';
				$output .= '<td>'.$prob["title"].'</td><td>'.$prob["description"].'</td><td>'.$prob["username"].'</td><td>'.$prob["datetime"]."</td><td>".$prob["severity"]."<td>".$prob["resolved"].'</td></tr>';
			}
		}
		$output .= '</table></form>';
		echo $output;
	}
	else{
		echo "<h1>You must be logged in to view this!  Redirecting to Login page...</h1>";
		header("Location: http://".HOST."/DevManagement/Login/login.php");
	}
	
	require_once '../../includes/footer.php';
?>